package com.service.actions;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.HibernateException;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.service.hibernate.dao.EmployeeDAO;
import com.service.hibernate.pojos.Employees;

@SuppressWarnings("serial")
public class EmployeeAction extends ActionSupport implements
ModelDriven<Employees>{

	
	Employees employee = new Employees();
	EmployeeDAO empDAO = new EmployeeDAO();
	List<Employees> employees = new ArrayList<Employees>();
	@Override
	public Employees getModel() {
		return employee;
		
	}
	
	public String viewEmployee() {
		try {
			
			System.out.println("Employee id is "+ employee.getId());
			employees=empDAO.getEmployee(employee.getId());
			
			return SUCCESS;
		} catch (HibernateException e) {
			return ERROR;
		}
		
	}
	
	
}
